<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    :keyboard="false"
    :forceRender="true"
    switchFullscreen
    @cancel="handleCancel"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 100%;overflow-y: hidden">
    <template slot="footer">
      <a-button @click="handleCancel">{{$t('inPrint.cancel')}}</a-button>
      <!-- <a-button v-if="isCanCheck" @click="handleOkAndCheck">{{$t('popup.saveReview')}}</a-button> -->
      <a-button type="primary" @click="handleOk" :disabled="confirmLoading">{{$t('commodityManagement.preservation')}}</a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row class="form-row" :gutter="24">
          <!-- <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('setailManagement.membershipCardNumber')">
              <a-select :placeholder="$t('manuManagement.number')" v-decorator="[ 'organId' ]" :disabled="!rowCanEdit"
                :dropdownMatchSelectWidth="false" showSearch optionFilterProp="children">
                <div slot="dropdownRender" slot-scope="menu">
                  <v-nodes :vnodes="menu" />
                  <a-divider style="margin: 4px 0;" />
                  <div v-if="isTenant" style="padding: 4px 8px; cursor: pointer;"
                       @mousedown="e => e.preventDefault()" @click="addMember"><a-icon type="plus" /> {{$t('popup.newMember')}}</div>
                </div>
                <a-select-option v-for="(item,index) in retailList" :key="index" :value="item.id">
                  {{ item.supplier }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col> -->
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('setailManagement.documentDate')">
              <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('setailManagement.documentNo')">
              <a-input :placeholder="$t('setailManagement.pleaseEnterTheDocumentNumber')" v-decorator.trim="[ 'number' ]" :readOnly="true"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('setailManagement.associatedDocument')">
              <a-input-search :placeholder="$t('popup.pleaseSelectAssociated')" v-decorator="[ 'linkNumber', validatorRules.linkNumber ]" @search="onSearchLinkNumber" :readOnly="true"/>
            </a-form-item>
          </a-col>
          
          <!-- 操作员 -->
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('defaultTranslate.operator')"
              data-step="3" :data-title="$t('defaultTranslate.operator')">
              <a-input :placeholder="$t('defaultTranslate.operator')" v-decorator.trim="['userName']"
                :readOnly="true" />
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24" v-show="false">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator.trim="['creator']" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row class="form-row" :gutter="24">
          <a-col :lg="18" :md="12" :sm="24">
            <j-editable-table id="billModal"
              :ref="refKeys[0]"
              :loading="materialTable.loading"
              :columns="materialTable.columns"
              :dataSource="materialTable.dataSource"
              :minWidth="minWidth"
              :maxHeight="300"
              :rowNumber="false"
              :rowSelection="rowCanEdit"
              :actionButton="rowCanEdit"
              :dragSort="rowCanEdit"
              @valueChange="barCodeValueChange"
              @inputPurchaseValueChange="onValueChange"
              @added="onAdded"
              @deleted="onDeleted">
              <template #buttonAfter>
                <a-row v-if="rowCanEdit" :gutter="24" style="float:left;padding-bottom: 5px;" data-step="4" :data-title="$t('popup.codeScanningEntry')" :data-intro="$t('popup.thisSupportsGun')">
                  <a-col v-if="scanStatus" :md="6" :sm="24">
                    <a-button @click="scanEnter">{{$t('popup.codeScanningEntry')}}</a-button>
                  </a-col>
                  <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 6px 0 12px">
                    <a-input :placeholder="$t('popup.pleaseScanBarcode')" v-model="scanBarCode" @pressEnter="scanPressEnter" ref="scanBarCode"/>
                  </a-col>
                  <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px">
                    <a-button @click="stopScan">{{$t('popup.stowScanningCode')}}</a-button>
                  </a-col>
                </a-row>
                <a-row :gutter="24" style="float:left;padding-bottom: 5px;">
                  <a-col :md="24" :sm="24">
                    <a-dropdown>
                      <a-menu slot="overlay">
                        <a-menu-item key="1" @click="handleBatchSetDepot"><a-icon type="setting"/>{{$t('popup.batchSettings')}}</a-menu-item>
                        <a-menu-item v-if="isTenant" key="2" @click="addDepot"><a-icon type="plus"/>{{$t('popup.newWarehouse')}}</a-menu-item>
                      </a-menu>
                      <a-button style="margin-left: 8px">{{$t('popup.warehouseOperation')}} <a-icon type="down" /></a-button>
                    </a-dropdown>
                  </a-col>
                </a-row>
              </template>
              <template #rowIndex="record">
                <div style="text-align: center;">{{ record.index + 1 }}</div>
              </template>
            </j-editable-table>
            <a-row class="form-row" :gutter="24">
              <a-col :lg="24" :md="24" :sm="24">
                <a-form-item :labelCol="labelCol" :wrapperCol="{xs: { span: 24 },sm: { span: 24 }}" label="">
                  <a-textarea :rows="1" :placeholder="$t('reportQuery.pleaseEnterComments')" v-decorator="[ 'remark' ]" style="margin-top:8px;"/>
                </a-form-item>
              </a-col>
            </a-row>
            <a-row class="form-row" :gutter="24">
              <a-col :lg="6" :md="12" :sm="24">
                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('popup.enclosure')">
                  <div v-if="fileLoading">Loading...</div>
              <j-upload v-else :fileList="fileList" bizPath="bill"></j-upload>
                </a-form-item>
              </a-col>
            </a-row>
          </a-col>
          <div class="sign">
            <a-col :lg="6" :md="12" :sm="24">
              <a-row class="form-row" :gutter="24">
                <a-col :lg="24" :md="6" :sm="6"><br/><br/></a-col>
                <a-col :lg="24" :md="6" :sm="6">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('inPrint.documentAmount')}}</span>
                    <a-input v-decorator.trim="[ 'changeAmount' ]" :style="{color:'purple'}" :readOnly="true"/>
                  </a-form-item>
                </a-col>
                <a-col :lg="24" :md="6" :sm="6">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('setailManagement.paymentAmount')}}</span>
                    <a-input v-decorator.trim="[ 'getAmount' ]" :style="{color:'red'}" defaultValue="0" @keyup="onKeyUpGetAmount"/>
                  </a-form-item>
                </a-col>
                <a-col :lg="24" :md="6" :sm="6">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('setailManagement.giveChange')}}</span>
                    <a-input v-decorator.trim="[ 'backAmount' ]" :style="{color:'green'}" :readOnly="true" defaultValue="0"/>
                  </a-form-item>
                </a-col>
                <a-col :lg="24" :md="6" :sm="6" v-show="false">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('setailManagement.giveChange')}}</span>
                    <a-input v-decorator.trim="[ 'discountLstAmount' ]" :style="{color:'green'}" :readOnly="true" defaultValue="0"/>
                  </a-form-item>
                </a-col>
                <a-col :lg="24" :md="6" :sm="6" v-show="false">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('setailManagement.giveChange')}}</span>
                    <a-input v-decorator.trim="[ 'otherMoney' ]" :style="{color:'green'}" :readOnly="true" defaultValue="0"/>
                  </a-form-item>
                </a-col>
                <a-col :lg="24" :md="6" :sm="6">
                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <span slot="label" style="font-size: 20px;line-height:20px">{{$t('financialManagement.paymentAccount')}}</span>
                    <a-select :placeholder="$t('financialManagement.selectPayment')" style="font-size:20px;" v-decorator="[ 'accountId', validatorRules.accountId ]" :dropdownMatchSelectWidth="false">
                      <div slot="dropdownRender" slot-scope="menu">
                        <v-nodes :vnodes="menu" />
                        <a-divider style="margin: 4px 0;" />
                        <div v-if="isTenant" style="padding: 4px 8px; cursor: pointer;"
                             @mousedown="e => e.preventDefault()" @click="addAccount"><a-icon type="plus" /> {{$t('popup.newAccount')}}</div>
                      </div>
                      <a-select-option v-for="(item,index) in accountList" :key="index" :value="item.id">
                        {{ item.name }}
                      </a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-col>
          </div>
        </a-row>
      </a-form>
    </a-spin>
    <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
    <member-modal ref="memberModalForm" @ok="memberModalFormOk"></member-modal>
    <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
    <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
    <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  </j-modal>
</template>
<script>
  import pick from 'lodash.pick'
  import LinkBillList from '../dialog/LinkBillList'
  import MemberModal from '../../system/modules/MemberModal'
  import DepotModal from '../../system/modules/DepotModal'
  import AccountModal from '../../system/modules/AccountModal'
  import BatchSetDepot from '../dialog/BatchSetDepot'
  import { FormTypes } from '@/utils/JEditableTableUtil'
  import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  import { BillModalMixin } from '../mixins/BillModalMixin'
  import { getMpListShort } from "@/utils/util"
  import { getAccount } from '@/api/api'
  import { getAction } from '@/api/manage'
  import JUpload from '@/components/jeecg/JUpload'
  import JDate from '@/components/jeecg/JDate'
  import Vue from 'vue'
  export default {
    name: "RetailBackModal",
    mixins: [JEditableTableMixin, BillModalMixin],
    components: {
      LinkBillList,
      MemberModal,
      DepotModal,
      AccountModal,
      BatchSetDepot,
      JUpload,
      JDate,
      VNodes: {
        functional: true,
        render: (h, ctx) => ctx.props.vnodes,
      }
    },
    data () {
      return {
        title:this.$t('setailManagement.operation'),
        width: '1600px',
        moreStatus: false,
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        visible: false,
        operTimeStr: '',
        prefixNo: 'CKTH',
        fileList:[],
        minWidth: 1100,
        rowCanEdit: true,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        refKeys: ['materialDataTable', ],
        activeKey: 'materialDataTable',
        materialTable: {
          loading: false,
          dataSource: [],
          columns: [
            { title: this.$t('defaultTranslate.lineNumber'), key: 'rowIndex', width: '5%', type: 'slot' },
            { title: this.$t('setailManagement.warehouseName'), key: 'depotName', width: '9%',readonly:true, type: FormTypes.input, placeholder: this.$t('inPrint.pleaseTnter')+'${title}', options: [],
              allowSearch:true, validateRules: [{ required: true, message: '${title}'+this.$t('inPrint.cannotTe') }]
            },
            { title: this.$t('setailManagement.warehouseName'), key: 'depotId', width: '9%',readonly:true, type: FormTypes.hidden, placeholder: this.$t('inPrint.pleaseTnter')+'${title}', options: [],
              allowSearch:true, validateRules: [{ required: true, message: '${title}'+this.$t('inPrint.cannotTe') }]
            },
            { title: this.$t('reportQuery.barcode'), key: 'barCode', width: '12%', type: FormTypes.hidden, kind: 'material', multi: true,
              // validateRules: [{ required: true, message: '${title}'+this.$t('inPrint.cannotTe') }]
            },
            
            { title: this.$t('reportQuery.name'), key: 'name', width: '9%',type: FormTypes.popupJsh, kind: 'material', multi: true },
            { title: this.$t('reportQuery.specification'), key: 'standard', width: '6%', type: FormTypes.normal },
            { title: this.$t('reportQuery.category'), key: 'categoryName', width: '6%', type: FormTypes.normal },
            { title: this.$t('reportQuery.specification'), key: 'meId', width: '6%', type: FormTypes.normal },
            { title: this.$t('reportQuery.model'), key: 'model', width: '6%', type: FormTypes.normal },
            { title: this.$t('reportQuery.color'), key: 'color', width: '5%', type: FormTypes.normal },
            { title: this.$t('reportQuery.extendedInformation'), key: 'materialOther', width: '7%', type: FormTypes.normal },
            { title: this.$t('reportQuery.inventory'), key: 'stock', width: '5%', type: FormTypes.normal },
            { title: this.$t('reportQuery.unit'), key: 'unit', width: '6%', type: FormTypes.normal },
            { title: this.$t('inPrint.serialNumber'), key: 'snList', width: '12%', type: FormTypes.input, placeholder:this.$t('popup.multipleSeparatedByCommas'),
              validateRules: [{ pattern: /^\S{1,100}$/, message: this.$t('popup.pleaseBeLess100') }]
            },
            { title: this.$t('commodityManagement.batchNumber'), key: 'batchNumber', width: '7%', type: FormTypes.input },
            { title: this.$t('inPrint.termValidity'), key: 'expirationDate',width: '9%', type: FormTypes.date },
            { title: this.$t('commodityManagement.multiAttribute'), key: 'sku', width: '5%', type: FormTypes.normal },
            { title: this.$t('reportQuery.quantity'), key: 'operNumber', width: '5%', type: FormTypes.inputNumber, statistics: true,
              validateRules: [{ required: true, message: '${title}'+this.$t('inPrint.cannotTe') }]
            },
            { title: this.$t('reportQuery.unitPrice'), key: 'unitPrice', width: '5%', type: FormTypes.inputNumber},
            { title: this.$t('reportQuery.amount'), key: 'allPrice', width: '5%', type: FormTypes.inputNumber, statistics: true },
            { title: this.$t('financialManagement.remarks'), key: 'remark', width: '7%', type: FormTypes.input },
            { title: '', key: 'discountPrice', width: '7%', type: FormTypes.hidden }
          ]
        },
        linkColumns:[
          {
            title: this.$t('manuManagement.documentNo'), dataIndex: 'number', width: 150,
            scopedSlots: { customRender: 'numberCustomRender' },
          },
          { title: this.$t('manuManagement.documentDate'), dataIndex: 'operTimeStr', width: 145 },
          { title: this.$t('manuManagement.operator'), dataIndex: 'loginName', width: 70 },
          { title: this.$t('manuManagement.totalAmount'), dataIndex: 'totalPrice', width: 70 },
          {
            title: this.$t('manuManagement.totalTaxIncluded'), dataIndex: 'totalTaxLastMoney', width: 70,
            customRender: function (text, record, index) {
              if (record.discountLastMoney && record.discountMoney ) {
                return (record.discountMoney + record.discountLastMoney).toFixed(2);
              } else {
                return record.totalPrice;
              }
            }
          },
          {
            title: this.$t('setailManagement.state'), dataIndex: 'status', width: 70, align: "center",
            scopedSlots: { customRender: 'customRenderStatus' }
          }
        ],
        columnsDetail:[
          { title: this.$t('reportQuery.name'), dataIndex: 'name', width: 130, ellipsis: true },
          { title: this.$t('reportQuery.specification'), dataIndex: 'standard', width: 130, ellipsis: true },
          { title: this.$t('reportQuery.category'), dataIndex: 'categoryName',width:80 },
        { title: this.$t('reportQuery.category'), dataIndex: 'categoryName',width:80 },
          { title: this.$t('setailManagement.warehouseName'),dataIndex:'depotName',width:130},
          { title: this.$t('reportQuery.unit'), dataIndex: 'unit', width: 50 },
          { title: this.$t('reportQuery.quantity'), dataIndex: 'operNumber', width: 80 },
          { title: this.$t('reportQuery.unitPrice'), dataIndex: 'unitPrice', width: 80 },
          { title: this.$t('reportQuery.amount'), dataIndex: 'allPrice', width: 80 },
          { title: this.$t('basicInformation.taxRate'), dataIndex: 'taxRate', width: 80 },
          { title: this.$t('inPrint.taxAmount'), dataIndex: 'taxMoney', width: 80 },
          { title: this.$t('inPrint.totalTax'), dataIndex: 'taxLastMoney', width: 80 },
          { title: this.$t('reportQuery.remarks'), dataIndex: 'remark', width: 100, ellipsis: true },
        ],
        confirmLoading: false,
        validatorRules:{
          operTime:{
            rules: [
              { required: true, message:this.$t('popup.pleaseEnterDocumentDate')+'!' }
            ]
          },
          accountId:{
            rules: [
              { required: true, message:this.$t('setailManagement.pleaseAccount')+'!' }
            ]
          },
          number:{
            rules: [
              { required: true, message: this.$t('otherJS.DocumentNoFailure') }
            ]
          },
          linkNumber:{
            rules: [
              { required: true, message: this.$t('popup.pleaseSelectAssociated') }
            ]
          }
        },
        url: {
          add: '/depotHead/addDepotHeadAndDetail',
          edit: '/depotHead/updateDepotHeadAndDetail',
          detailList: '/depotItem/getDetailList'
        }
      }
    },
    created () {
      let realScreenWidth = window.screen.width
      this.minWidth = realScreenWidth<1500?900:1100
    },
    methods: {
      //调用完edit()方法之后会自动调用此方法
      editAfter() {
        this.billStatus = '0'
        this.rowCanEdit = true
        this.changeColumnHide()
        this.changeFormTypes(this.materialTable.columns, 'snList', 0)
        this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
        this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
        if (this.action === 'add') {
          this.addInit(this.prefixNo)
          this.fileList = []
          this.$nextTick(() => {
            this.form.setFieldsValue({'getAmount':0, 'backAmount':0})
          })
        } else {
          if(this.model.linkNumber) {
            this.rowCanEdit = false
            this.materialTable.columns[1].type = FormTypes.normal
          }
          this.model.operTime = this.model.operTimeStr
          if(this.model.backAmount) {
            this.model.getAmount = (this.model.changeAmount + this.model.backAmount).toFixed(2)
          } else {
            this.model.getAmount = this.model.changeAmount
          }
          
          this.$nextTick(() => {
            this.form.setFieldsValue(pick(this.model,'organId', 'operTime', 'number', 'linkNumber', 'remark',
              'discount','discountMoney','discountLastMoney','otherMoney','accountId','changeAmount','getAmount','backAmount'))
          });
          // 加载子表数据
          let params = {
            headerId: this.model.id,
            mpList: getMpListShort(Vue.ls.get('materialPropertyList'))  //扩展属性
          }
          let url = this.readOnly ? this.url.detailList : this.url.detailList;
          this.requestSubTableData(url, params, this.materialTable);
        }
        //复制新增单据-初始化单号和日期
        if(this.action === 'copyAdd') {
          this.model.id = ''
          this.model.tenantId = ''
          this.copyAddInit(this.prefixNo)
        }
        this.initRetail()
        this.initDepot()
        this.initAccount()
      },
      //提交单据时整理成formData
      classifyIntoFormData(allValues) {
        let totalPrice = 0
        let billMain = Object.assign(this.model, allValues.formValue)
        let detailArr = allValues.tablesValue[0].values
        billMain.type = '入库'
        billMain.subType = '仓库退货'
        billMain.defaultNumber = billMain.number
        billMain.discountLastMoney = billMain.changeAmount
        billMain.otherMoney = 0
        for(let item of detailArr){
          totalPrice += item.allPrice-0
          item.discountAllPrice =  this.$toDecimal(item.operNumber *(item.discountPrice  - item.unitPrice ))//折扣额
        }
        billMain.totalPrice = 0-totalPrice
        billMain.changeAmount = 0-billMain.changeAmount
        // if(this.fileList && this.fileList.length > 0) {
        //   billMain.fileName = this.fileList
        // } else {
        //   billMain.fileName = ''
        // }
        if(this.model.id){
          billMain.id = this.model.id
        }
        billMain.status = this.billStatus
        let fileList = JSON.stringify(JSON.parse(localStorage.getItem("fileList")))
        return {
          info: JSON.stringify(billMain),
          attachment: fileList,
          rows: JSON.stringify(detailArr),
        }
      },
      initAccount(){
        getAccount({}).then((res)=>{
          if(res && res.code === 200) {
            this.accountList = res.data.accountList
          }
        })
      },
      
      //改变优惠、本次付款、欠款的值
      autoChangePrice (target) {
        console.log('777 :>> ', 777);
        let {values} = target.getValuesAsync((e,v)=>v.values)
        // 不能使用target.statisticsColumns统计的方式计算了，价格权限会导致获取不到值
        // 也不能用dataSource,因为target.set不会触发dataSource更新
        let allTaxLastMoney = values.reduce((pre,item,index)=>{
          return pre + +item.taxLastMoney
        },0) || 0
        // let discount = this.form.getFieldValue('discount') - 0
        let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
        let deposit = this.form.getFieldValue('deposit')
        // 之前的优惠率
        // let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
        console.log('allTaxLastMoney :>> ', allTaxLastMoney);
        let discountMoney = (0 * allTaxLastMoney)
        console.log('discountMoney',discountMoney);
        let discountLastMoney = this.$toDecimal(allTaxLastMoney - discountMoney)
        console.log('discountLastMoney',discountLastMoney);

        let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
        if (deposit) {
          changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
        }
        this.$nextTick(() => {
          changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' || this.prefixNo === 'CGRK' ? 0 : changeAmountNew
          this.form.setFieldsValue({
            discountMoney: discountMoney,
            discountLastMoney: discountLastMoney,
            debt: 0,
            changeAmount: 0
          })
        })
      },
      
      //改变实收金额、收款金额的值
      autoChangePrice(target) {
        const table = this.$refs[this.refKeys]
        table.getValues((e,v)=>{
          let allLastMoney = v.reduce((total,item)=>{
            return this.$toDecimal(total + (+item.allPrice))
          },0)
          this.$nextTick(() => {
            this.form.setFieldsValue({'changeAmount':allLastMoney,'getAmount':allLastMoney,'backAmount':0})
          });
        })
      },
      //改变收款金额
      onKeyUpGetAmount(e) {
        const value = e.target.value
        let changeAmount = this.form.getFieldValue('changeAmount')-0
        let backAmount = (value - changeAmount).toFixed(2)-0
        this.$nextTick(() => {
          this.form.setFieldsValue({'backAmount':backAmount})
        });
      },
      onSearchLinkNumber() {
        this.$refs.linkBillList.show('出库','零售销售', '', "1",'',this.prefixNo)
        this.$refs.linkBillList.setColumns(this.linkColumns,this.columnsDetail)
        this.$refs.linkBillList.title = this.$t('setailManagement.storeOut')
      },
      linkBillListOk(selectBillDetailRows, linkNumber, organId, discount, deposit, remark) {
        this.rowCanEdit = false
        if(selectBillDetailRows && selectBillDetailRows.length>0) {
          let listEx = []
          let allTaxLastMoney = 0
          for(let j=0; j<selectBillDetailRows.length; j++) {
            let info = selectBillDetailRows[j];
            allTaxLastMoney += info.allPrice
            listEx.push(info)
            this.changeColumnShow(info)
          }
          this.materialTable.dataSource = listEx
          ///给优惠后金额重新赋值
          if(allTaxLastMoney) {
            let discountLastMoney = (allTaxLastMoney).toFixed(2)-0
            this.$nextTick(() => {
              this.form.setFieldsValue({
                'organId': organId,
                'linkNumber': linkNumber,
                'getAmount': discountLastMoney,
                'changeAmount': discountLastMoney,
                'backAmount': 0,
                'remark': remark
              })
            })
          }
        }
      },
    }
  }
</script>
<style scoped>
  .sign .ant-input{
    font-size: 30px;
    font-weight:bolder;
    text-align:center;
    border-left-width:0px!important;
    border-top-width:0px!important;
    border-right-width:0px!important;
  }
</style>